package com.ycfmedical.bed.adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.SwitchCompat;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.CompoundButton;
import android.widget.TextView;

import com.ycfmedical.bed.R;
import com.ycfmedical.bed.local.entity.TimerReminder;

import org.greenrobot.greendao.annotation.Entity;

import butterknife.BindView;
import butterknife.OnClick;
import cn.droidlover.xdroidmvp.base.SimpleRecAdapter;
import cn.droidlover.xdroidmvp.kit.KnifeKit;
import cn.droidlover.xdroidmvp.log.XLog;

/**
 * Created by Administrator on 2017/3/20 0020.
 */
public class TimerReminderAdapter extends SimpleRecAdapter<TimerReminder, TimerReminderAdapter.ViewHolder>
{
    public static final int TAG_POST = 0;
    public static final int TAG_DELETE = 1;

    public TimerReminderAdapter(Context context)
    {
        super(context);
    }

    @Override
    public ViewHolder newViewHolder(View itemView)
    {
        return new ViewHolder(itemView);
    }

    @Override
    public int getLayoutId()
    {
        return R.layout.adapter_timer_reminder;
    }


    @Override
    public void onBindViewHolder(final ViewHolder holder, final int position)
    {
        final TimerReminder timerReminder= data.get(position);
        holder.remindCounts.setText("每天");
        holder.remindTime.setText(timerReminder.getReminderTime());
        holder.timerSwich.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener()
        {
            @Override
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked)
            {
                if (isChecked)
                {

                }
                else
                {

                }
            }
        });

        holder.deleteTimerItem.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (getRecItemClick() != null)
                {
                    getRecItemClick().onItemClick(position, timerReminder, TAG_DELETE, holder);
                }
            }
        });

    }

    @OnClick({R.id.timer_swich, R.id.delete_timerItem})
    public void onViewClicked(View view)
    {
        switch (view.getId())
        {
            case R.id.timer_swich:
                break;
            case R.id.delete_timerItem:
                break;
        }
    }


    public static class ViewHolder extends RecyclerView.ViewHolder
    {
        @BindView(R.id.remindCounts)
        TextView remindCounts;
        @BindView(R.id.remindTime)
        TextView remindTime;
        @BindView(R.id.timer_swich)
        SwitchCompat timerSwich;
        @BindView(R.id.delete_timerItem)
        Button deleteTimerItem;

        public ViewHolder(View itemView)
        {
            super(itemView);
            KnifeKit.bind(this, itemView);
        }
    }
}
